<?php

namespace app\api\model\goods;

use think\Model;


class GoodsDetails extends Model
{

    

    

    // 表名
    protected $name = 'goods_details';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        
    ];
    

    
    public function getTypeList()
    {
        return ['20' => __('Type 20'), '30' => __('Type 30')];
    }


    public function getTypeTextAttr($value, $data)
    {
        $value = $value ?: ($data['type'] ?? '');
        $list = $this->getTypeList();
        return $list[$value] ?? '';
    }

    public function goods()
    {
        return $this->hasOne('app\admin\model\goods\Goods', 'id', 'goods_id')->bind(['title', 'image', 'price', 'original_price', 'goods_no']);
    }




}
